package com.by.common.controller;

import com.by.common.bean.ResultBean;
import com.by.common.exception.ValidateException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice //异常增强注解
public class GlobalExceptionController extends BaseController{
    /**
     * 捕获后端验证异常
     * @param e
     * @return
     */
    @ExceptionHandler
    public ResultBean handlerValidationException(ValidateException e){
        return fail("验证失败",e.getErrorMap());
    }
}
